<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
	<title>Cadastro de CheckLists</title>
</h:head>
<ui:composition template="templatePrincipal.xhtml">
	<ui:define name="header">
		<ui:include src="header.xhtml" />
	</ui:define>

	<ui:define name="centro">
		<h:body>

			<p:growl id="messages" showDetail="true" life="1000" />
			<p:confirmDialog id="confirmRemoveDialog"
				message="Remover o check list ?" header="Remoção de check list"
				severity="alert" widgetVar="confirmation" appendToBody="true"
				update="messages">

				<p:commandButton id="confirm" value="Sim"
					oncomplete="confirmation.hide()"
					actionListener="#{checkListController.removeCheckList}"
					update="messages,form1:tabview1:dataTable,form1:tabview1:dados" />

				<p:commandButton id="decline" value="Não"
					onclick="confirmation.hide()" type="button" />

			</p:confirmDialog>

			<h:form id="form1" prependId="false">

				<p:tabView id="tabview1" dynamic="true" cache="false">
					<p:ajax event="tabChange"
						listener="#{checkListController.changeTabView}" update="novocli" />


					<p:tab id="tabpesq" title="Pesquisar">
						<p:panel header="Check Lists">
							<p:panelGrid id="dados" columns="4">

								<f:facet name="header">
        						Dados da pesquisa
    						</f:facet>

								<p:outputLabel for="pesqtitulo" value="Titulo :" />
								<p:inputText id="pesqtitulo"
									value="#{checkListController.pesqchkHeader.titulo}" />

								<p:outputLabel for="pesqoperacao" value="Operação :" />
								<p:inputText id="pesqoperacao"
									value="#{checkListController.pesqchkHeader.operacao}" />

								<p:outputLabel for="pesqtipo" value="Tipo :" />
								<p:inputText id="pesqtipo"
									value="#{checkListController.pesqchkHeader.tipo}" />

								<p:outputLabel for="pesqmodalidade1" value="Modalidade 1 :" />
								<p:inputText id="pesqmodalidade1"
									value="#{checkListController.pesqchkHeader.modalidade1}" />

								<p:outputLabel for="pesqmodalidade2" value="Modalidade 2 :" />
								<p:inputText id="pesqmodalidade2"
									value="#{checkListController.pesqchkHeader.modalidade2}" />

								<p:commandButton value="Pesquisar"
									actionListener="#{checkListController.pegarTodosChkList}"
									update="dataTable,dados" />

							</p:panelGrid>

							<p:dataTable id="dataTable" var="chkHeader"
								value="#{checkListController.chkHeaderList}" paginator="true"
								rows="3"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="3,6,9"
								selection="#{checkListController.reschkHeader}"
								selectionMode="single" rowKey="#{chkHeader.chkHeader_id}">

								<p:ajax event="rowSelect"
									listener="#{checkListController.rowSelect}"
									update=":form1:tabview1:dados,:form1:tabview1:dataTableImoveis" />


								<f:facet name="header">
            					Check Lists encontrados
        					</f:facet>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Titulo" />
									</f:facet>
									<h:outputText value="#{chkHeader.titulo}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Operação" />
									</f:facet>
									<h:outputText value="#{chkHeader.operacao}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Tipo" />
									</f:facet>
									<h:outputText value="#{chkHeader.tipo}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Modalidade 1" />
									</f:facet>
									<h:outputText value="#{chkHeader.modalidade1}" />
								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Modalidade 2" />
									</f:facet>
									<h:outputText value="#{chkHeader.modalidade2}" />
								</p:column>

							</p:dataTable>

							<p:commandButton value="Remover" onclick="confirmation.show()"
								type="button" />

							<p:commandButton value="Salvar"
								actionListener="#{checkListController.saveCheckList}"
								update="dados,dataTable,:messages" />

							<p:commandButton value="Cancelar" type="reset" />
						</p:panel>
						<p:panel header="Linhas do CheckList">

							<p:dataTable id="dataTableImoveis" var="chkLines"
								value="#{checkListController.reschkHeader.checkLines}"
								paginator="true" rows="10"
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
								rowsPerPageTemplate="10,20,30"
								selection="#{checkListController.selectedChkLine}"
								selectionMode="single" rowKey="#{chkLines.chkLine_id}">


								<f:facet name="header">
            						Linhas do check list
        						</f:facet>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Descrição" />
									</f:facet>
									<p:inputText value="#{chkLines.descricao}" size="100" />

								</p:column>

								<p:column>
									<f:facet name="header">
										<h:outputText value="Grupo" />
									</f:facet>

									<p:inputText value="#{chkLines.grupo}" size="100" />
								</p:column>
							</p:dataTable>

							<p:commandButton id="insereImovelbnt" value="Adiciona Linha"
								actionListener="#{checkListController.adicionaChkLine}"
								update="dataTableImoveis,:messages" />

							<p:commandButton id="removeImovelbnt" value="Remove Linha"
								actionListener="#{checkListController.removeLinha}"
								update="dataTableImoveis,:messages" />


						</p:panel>
					</p:tab>

					<p:tab id="tabnovocli" title="Novo CheckList">

						<p:panelGrid id="novocli" columns="4">
							<f:facet name="header">
        					Dados do CheckList
    					</f:facet>

							<p:outputLabel for="novo_titulo" value="Titulo :" />
							<p:inputText id="novo_titulo"
								value="#{checkListController.chkHeader.titulo}" />

							<p:outputLabel for="novo_operacao" value="Operação :" />
							<p:inputText id="novo_operacao"
								value="#{checkListController.chkHeader.operacao}" />

							<p:outputLabel for="novo_tipo" value="Tipo :" />
							<p:inputText id="novo_tipo"
								value="#{checkListController.chkHeader.tipo}" />

							<p:outputLabel for="novo_modalidade1" value="Modalidade 1 :" />
							<p:inputText id="novo_modalidade1"
								value="#{checkListController.chkHeader.modalidade1}" />

							<p:outputLabel for="novo_modalidade2" value="Modalidade 2 :" />
							<p:inputText id="novo_modalidade2"
								value="#{checkListController.chkHeader.modalidade2}" />


							<p:commandButton value="Salvar"
								actionListener="#{checkListController.createChkHeader}"
								update="novocli,:messages" />

							<p:commandButton value="Cancelar" type="reset" />

						</p:panelGrid>

					</p:tab>

					<p:tab tab="importar" title="Importar">
						<h:form enctype="multipart/form-data">
							<p:fileUpload
								fileUploadListener="#{checkListController.handleFileUpload}"
								mode="advanced" update=":messages" auto="true" />
						</h:form>
					</p:tab>
				</p:tabView>

			</h:form>
		</h:body>
	</ui:define>
</ui:composition>
</html>